home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / cxxp4w.zip / INCLUDE / WINDOW.HPP
C/C++ Source or Header  |  1993-03-11  |  3KB  |  138 lines

  1. #ifndef    WINDOW_INC
  2. #define    WINDOW_INC
  3.  
  4. #include "winobj.hpp"
  5.  
  6. extern "C" {
  7. LONG CALLBACK CPPWinProc(HWND, UINT, UINT, LONG);
  8. }
  9.  
  10. #define WM_USER_DELETE     WM_USER+0x300
  11. #define WM_USER_DESTROY    WM_USER+0x301
  12.  
  13. class Event {
  14.  
  15. public:
  16. UINT wParam;
  17. LONG lParam;
  18.  
  19. Event(UINT w, LONG l) {wParam=w; lParam=l;};
  20. }; // class Event
  21.  
  22. typedef struct {
  23.   int RepeatCount:16,
  24.       ScanCode:8,
  25.       fExtended:1,
  26.       reserved1:4,
  27.       fAlt:1,
  28.       fPrev:1,
  29.       fTransition:1;
  30. } KEYCODES;
  31.  
  32.  
  33. class Window: public  WinObj    {
  34. protected :
  35. //#ifdef WIN32
  36. //  WNDPROC DefaultHandler;
  37. //  static WNDPROC Handler;
  38. //#else
  39.   FARPROC DefaultHandler;    // default callback
  40.   static FARPROC Handler;    // proc instance
  41. //#endif
  42.   void SetHandler();
  43.   static HANDLE hAccel;
  44.  
  45. public:
  46.   Window();            // void constructor
  47.   ~Window();
  48.  
  49. protected:
  50.   void Create(                  // Create a window
  51.     LPSTR pCaption,             // Caption
  52.     LONG  Style,
  53.     int x,                      // Position
  54.     int y,
  55.     int width,                  // Size
  56.     int height,
  57.     HWND hPwnd,                 // Parent handle
  58.     HMENU hMenu=NULL);
  59.  
  60. public:    
  61.   Window * HorzScrollBar;
  62.   Window * VertScrollBar;
  63.  
  64.   HWND hWnd;                    // Window handle
  65.  
  66.   friend  LONG CALLBACK CPPWinProc(
  67.     HWND hWnd, UINT msg, UINT wParam, LONG lParam);
  68.  
  69.   virtual int MessageLoop();
  70.   virtual LONG MessageProc(
  71.     HWND hWnd,
  72.     unsigned msg,
  73.     Event& evt);
  74.  
  75.   virtual LPSTR Register(WNDCLASS& wc);
  76.  
  77.   void Move(
  78.     RECT *rc,                   // Move the window
  79.     BOOL repaint=TRUE);
  80.  
  81.   BOOL Show(                    // Show or hide the window
  82.     int nCmdShow=SW_SHOW){
  83.     return ShowWindow(hWnd,nCmdShow);};
  84.  
  85.   int GetText(                  // Get window text
  86.     LPSTR pBuffer,
  87.     int Size){
  88.     return SendMessage(hWnd,WM_GETTEXT,Size,(LONG)pBuffer);};
  89.  
  90.   int SetText(                  // Set window text
  91.     LPSTR pBuffer){
  92.     return SendMessage(hWnd,WM_SETTEXT,0,(LONG)pBuffer);};
  93.  
  94. #ifdef __BORLANDC__
  95.   #pragma warn -par
  96. #endif                          // Virtual event methods
  97.   virtual BOOL  InitMenu(HMENU hMenu)
  98.     {return FALSE;};
  99.   virtual BOOL  QueryClose()
  100.     {return TRUE;};
  101.   virtual BOOL  Size( UINT Width, UINT Height, UINT Type);
  102.   virtual BOOL  Char(UINT Value, UINT Repeat)
  103.     {return FALSE;};
  104.   virtual BOOL  KeyDown(UINT VirtKey, KEYCODES KeyCodes)
  105.     {return FALSE;};
  106.   virtual BOOL  LButtonDown(POINT Cursor, UINT Keys)
  107.     {return FALSE;};
  108.   virtual BOOL  LButtonDblClk(POINT Cursor, UINT Keys)
  109.     {return FALSE;};
  110.   virtual BOOL  MouseMove(POINT Cursor, UINT Keys)
  111.     {return FALSE;};
  112.   virtual BOOL  MouseActivate(HWND hTop, UINT HitTest)
  113.     {return FALSE;};
  114.   virtual BOOL  LButtonUp(POINT Cursor, UINT Keys)
  115.     {return FALSE;};
  116.   virtual BOOL  RButtonDown(POINT Cursor, UINT Keys)
  117.     {return FALSE;};
  118.   virtual BOOL  RButtonUp(POINT Cursor, UINT Keys)
  119.     {return FALSE;};
  120.   virtual BOOL  Paint();
  121.   virtual BOOL  SetFocus (HWND hPrev)
  122.     {return FALSE;};
  123.   virtual BOOL  KillFocus (HWND hNext)
  124.     {return FALSE;};
  125.   virtual BOOL  Command( UINT Id, UINT Code, HWND hControl);
  126.   virtual BOOL  DialogMessage(MSG& msg){return FALSE;};
  127.  
  128. #ifdef __BORLANDC__
  129.   #pragma warn +par
  130. #endif
  131. }; // class Window
  132.  
  133. extern void PutWin(HWND hWnd, Window * pWin);
  134. extern Window * GetWin(HWND hWnd);
  135. extern Window * DelWin(HWND hWnd);
  136.  
  137. #endif // WINDOW_INC
  138.